package com.zwps.common.controller.response.message;

import java.util.List;

import com.zwps.common.controller.model.vo.ParameterNotMeetRequireVO;
import com.zwps.common.core.exception.status.CommonExceptionStatus;
import com.zwps.extra.http.response.message.DefaultResponseDataMessage;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

@Schema(description = "响应数据基础结构")
@Getter
public class ResponseDataMessage<T> extends DefaultResponseDataMessage<T> {

    @Schema(description = "处理结果")
    private boolean success;

    @Schema(description = "处理结果状态码")
    @Override
    public Integer getCode() {
        return super.getCode();
    }
    
    @Schema(description = "处理结果消息")
    @Override
    public String getMessage() {
        return super.getMessage();
    }

    @Schema(description = "响应数据")
    @Override
    public T getData() {
        return super.getData();
    }
    
    public ResponseDataMessage() {
    }

    private ResponseDataMessage(Integer code, String message, T data, boolean success) {
        super(code, message);
        super.data = data;
        this.success = success;
    }

    public static <T> ResponseDataMessage<T> data(T data) {
        CommonExceptionStatus status = CommonExceptionStatus.USER_ACTION_SUCCESS;
        return new ResponseDataMessage<T>(status.getCode(), status.getDescribe(), data, true);
    }

    public static ResponseDataMessage<List<ParameterNotMeetRequireVO>> parameterNotMeetRequireMessage(
            List<ParameterNotMeetRequireVO> fields) {
        CommonExceptionStatus status = CommonExceptionStatus.PARAMETER_NOT_MEET_REQUIRE;
        return new ResponseDataMessage<List<ParameterNotMeetRequireVO>>(status.getCode(), status.getDescribe(), fields,
                false);
    }
}
